Part Number Hot Search : 
01547 HC705J2 312D5WFR 4N100 TS3021 6A0LMF B18T1 3SK88
Product Description
Full Text Search
 

To Download DS41401A Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  ? 2009 microchip technology inc. DS41401A f1 evaluation platform for enhanced pic ? microcontrollers user?s guide
DS41401A-page 2 ? 2009 microchip technology inc. information contained in this publication regarding device applications and the like is provided only for your convenience and may be superseded by updates. it is your responsibility to ensure that your application meets with your specifications. microchip makes no representations or warranties of any kind whether express or implied, written or oral, statutory or otherwise, related to the information, including but not limited to its condition, quality, performance, merchantability or fitness for purpose . microchip disclaims all liability arising from this information and its use. use of microchip devices in life support and/or safety applications is entirely at the buyer?s risk, and the buyer agrees to defend, indemnify and hold harmless microchip from any and all damages, claims, suits, or expenses resulting from such use. no licenses are conveyed, implicitly or otherwise, under any microchip intellectual property rights. trademarks the microchip name and logo, the microchip logo, dspic, k ee l oq , k ee l oq logo, mplab, pic, picmicro, picstart, rfpic and uni/o are registered trademarks of microchip technology incorporated in the u.s.a. and other countries. filterlab, hampshire, hi-tech c, linear active thermistor, mxdev, mxlab, seeval and the embedded control solutions company are registered trademarks of microchip technology incorporated in the u.s.a. analog-for-the-digital age, appl ication maestro, codeguard, dspicdem, dspicdem.net, dspicworks, dsspeak, ecan, economonitor, fansense, hi-tide, in-circuit serial programming, icsp, mindi, miwi, mpasm, mplab certified logo, mplib, mplink, mtouch, octopus, omniscient code generation, picc, picc-18, picdem, picdem.net, pickit, pictail, pic 32 logo, real ice, rflab, select mode, total endurance, tsharc, uniwin driver, wiperlock and zena are trademarks of microchip technology incorporated in the u.s.a. and other countries. sqtp is a service mark of microchip technology incorporated in the u.s.a. all other trademarks mentioned herein are property of their respective companies. ? 2009, microchip technology incorporated, printed in the u.s.a., all rights reserved. printed on recycled paper. note the following details of the code protection feature on microchip devices: ? microchip products meet the specification cont ained in their particular microchip data sheet. ? microchip believes that its family of products is one of the mo st secure families of its kind on the market today, when used i n the intended manner and under normal conditions. ? there are dishonest and possibly illegal methods used to breach the code protection feature. all of these methods, to our knowledge, require using the microchip produc ts in a manner outside the operating specifications contained in microchip?s data sheets. most likely, the person doing so is engaged in theft of intellectual property. ? microchip is willing to work with the customer who is concerned about the integrity of their code. ? neither microchip nor any other semiconductor manufacturer c an guarantee the security of their code. code protection does not mean that we are guaranteeing the product as ?unbreakable.? code protection is constantly evolving. we at microchip are co mmitted to continuously improvi ng the code protection features of our products. attempts to break microchip?s c ode protection feature may be a violation of the digital millennium copyright act. if such acts allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that act. microchip received iso/ts-16949:2002 certification for its worldwide headquarters, design and wafer fabrication facilities in chandler and tempe, arizona; gresham, oregon and design centers in california and india. the company?s quality system processes and procedures are for its pic ? mcus and dspic ? dscs, k ee l oq ? code hopping devices, serial eeproms, microperipherals, nonvolatile memory and analog products. in addition, microchip?s quality system for the design and manufacture of development systems is iso 9001:2000 certified.
f1 evaluation platform user?s guide ? 2009 microchip technology inc. DS41401A-page 3 table of contents preface ....................................................................................................................... .... 5 chapter 1. f1 evaluation platform overview 1.1 introduction ................................................................................................... 11 1.2 platform contents ......................................................................................... 11 1.3 hardware features ....................................................................................... 11 chapter 2. getting started 2.1 introduction ................................................................................................... 13 2.2 powering the f1 evaluation platform ........................................................... 13 2.3 powering with pickit? 3 .............................................................................. 13 2.4 powering with the connector at jp3 ............................................................ 14 2.5 powering with pickit? serial ....................................................................... 14 2.6 powering with the bldc expansion header j3 ........................................... 15 2.7 default firmware .......................................................................................... 15 chapter 3. programming the f1 evaluation platform 3.1 introduction ................................................................................................... 17 3.2 programming/development tool support .................................................... 17 3.3 hardware resources .................................................................................... 18 chapter 4. demo code 4.1 introduction ................................................................................................... 19 4.2 i 2 c? demo .................................................................................................. 19 4.3 lcd demo .................................................................................................... 19 4.4 bldc demo ................................................................................................. 19 4.5 combined demo .......................................................................................... 19 chapter 5. hardware libraries and drivers 5.1 introduction ................................................................................................... 21 5.2 i 2 c? driver .................................................................................................. 21 5.3 mcp9800 driver ........................................................................................... 21 5.4 rtcc driver ................................................................................................. 21 5.5 lcd driver .................................................................................................... 21 5.6 using the i 2 c? driver .................................................................................. 22 5.7 using the lcd driver .................................................................................... 24 5.8 using the rtcc driver ................................................................................. 26 5.9 using the mcp9800 driver ........................................................................... 27 chapter 6. troubleshooting 6.1 introduction ................................................................................................... 29 6.2 common problems ....................................................................................... 29
f1 evaluation platform user?s guide DS41401A-page 4 ? 2009 microchip technology inc. chapter 7. schematics 7.1 introduction .................................................................................................. 31 index ......................................................................................................................... ....39 worldwide sales and service .....................................................................................42
? 2009 microchip technology inc. DS41401A-page 5 f1 evaluation platform user?s guide preface introduction this chapter contains general information that will be useful to know before using the f1 evaluation platform user?s guide. items discussed in this chapter include: ? document layout ? conventions used in this guide ? warranty registration ? recommended reading ? the microchip web site ? development systems customer change notification service ? customer support ? document revision history document layout this document describes how to use the f1 evaluation platform user?s guide as a development tool to emulate and debug firmware on a target board. the manual layout is as follows: ? chapter 1. ?f1 evaluation platform overview? ? chapter 2. ?getting started? ? chapter 3. ?programming the f1 evaluation platform? ? chapter 4. ?demo code? ? chapter 5. ?hardware libraries and drivers? ? chapter 6. ?troubleshooting? ? chapter 7. ?schematics? notice to customers all documentation becomes dated, and this manual is no exception. microchip tools and documentation are constantly evolving to meet customer needs, so some actual dialogs and/or tool descriptions may differ from those in this document. please refer to our web site (www.microchip.com) to obtain the latest documentation available. documents are identified with a ?ds? number. this number is located on the bottom of each page, in front of the page number. the numbering convention for the ds number is ?dsxxxxxa?, where ?xxxxx? is the document number and ?a? is the revision level of the document. for the most up-to-date information on development tools, see the mplab ? ide on-line help. select the help menu, and then topics to open a list of available on-line help files.
f1 evaluation platform user?s guide DS41401A-page 6 ? 2009 microchip technology inc. conventions used in this guide this manual uses the following documentation conventions: documentation conventions description represents examples arial font: italic characters referenced books mplab ? ide user?s guide emphasized text ...is the only compiler... initial caps a window the output window a dialog the settings dialog a menu selection select enable programmer quotes a field name in a window or dialog ?save project before build? underlined, italic text with right angle bracket a menu path file>save bold characters a dialog button click ok a tab click the power tab n?rnnnn a number in verilog format, where n is the total number of digits, r is the radix and n is a digit. 4?b0010, 2?hf1 text in angle brackets < > a key on the keyboard press , courier new font: plain courier new sample source code #define start filenames autoexec.bat file paths c:\mcc18\h keywords _asm, _endasm, static command-line options -opa+, -opa- bit values 0, 1 constants 0xff, ?a? italic courier new a variable argument file .o , where file can be any valid filename square brackets [ ] optional arguments mcc18 [options] file [options] curly brackets and pipe character: { | } choice of mutually exclusive arguments; an or selection errorlevel {0|1} ellipses... replaces repeated text var_name [, var_name...] represents code supplied by user void main (void) { ... }
preface ? 2009 microchip technology inc. DS41401A-page 7 warranty registration please complete the enclosed warranty registration card and mail it promptly. sending in the warranty registration card entitles users to receive new product updates. interim software releases are available at the microchip web site. recommended reading this user?s guide describes how to use f1 evaluation platform user?s guide. other useful documents are listed below. the following microchip documents are available and recommended as supplemental reference resources. readme for f1 evaluation platform user?s guide for the latest information on using f1 evaluation platform user?s guide, read the ? readme for f1 evaluation platform user?s guide.txt ? file (an ascii text file) in the readmes subdirectory of the mplab ide installation directory. the readme file contains update information and known issues that may not be included in this user?s guide. readme files for the latest information on using other tools, read the tool-specific readme files in the readmes subdirectory of the mplab ide installation directory. the readme files contain update information and known issues that may not be included in this user?s guide.
f1 evaluation platform user?s guide DS41401A-page 8 ? 2009 microchip technology inc. the microchip web site microchip provides online support via our web site at www.microchip.com. this web site is used as a means to make files and information easily available to customers. accessible by using your favorite internet browser, the web site contains the following information: ? product support ? data sheets and errata, application notes and sample programs, design resources, user?s guides and hardware support documents, latest software releases and archived software ? general technical support ? frequently asked questions (faqs), technical support requests, online discussion groups, microchip consultant program member listing ? business of microchip ? product selector and ordering guides, latest microchip press releases, listing of seminars and events, listings of microchip sales offices, distributors and factory representatives development systems custome r change notification service microchip?s customer notification service helps keep customers current on microchip products. subscribers will receive e-mail notification whenever there are changes, updates, revisions or errata related to a specified product family or development tool of interest. to register, access the microchip web site at www.microchip.com, click on customer change notification and follow the registration instructions. the development systems product group categories are: ? compilers ? the latest information on microchip c compilers and other language tools. these include the mplab c18 and mplab c30 c compilers; mpasm? and mplab asm30 assemblers; mplink? and mplab link30 object linkers; and mplib? and mplab lib30 object librarians. ? emulators ? the latest information on microchip in-circuit emulators.this includes the mplab ice 2000 and mplab ice 4000. ? in-circuit debuggers ? the latest information on the microchip in-circuit debugger, mplab icd 2. ? mplab ? ide ? the latest information on microchip mplab ide, the windows ? integrated development environment for development systems tools. this list is focused on the mplab ide, mplab sim simulator, mplab ide project manager and general editing and debugging features. ? programmers ? the latest information on microchip programmers. these include the mplab pm3 and pro mate ? ii device programmers and the picstart ? plus and pickit? 1 development programmers.
preface ? 2009 microchip technology inc. DS41401A-page 9 customer support users of microchip products can receive assistance through several channels: ? distributor or representative ? local sales office ? field application engineer (fae) ? technical support customers should contact their distributor, representative or field application engineer (fae) for support. local sales offices are also available to help customers. a listing of sales offices and locations is included in the back of this document. technical support is available through the web site at: http://support.microchip.com document revision history revision a (october 2009) ? initial release of this document.
f1 evaluation platform user?s guide DS41401A-page 10 ? 2009 microchip technology inc. notes:
f1 evaluation platform user?s guide ? 2009 microchip technology inc. DS41401A-page 11 chapter 1. f1 evaluation platform overview 1.1 introduction thank you for choosing the f1 evaluation platform. this kit allows you to begin development on the pic16lf1937. the pic16lf1937 is the first of the enhanced mid-range microcontrollers. these architectural enhancements allow for more memory and faster computation than that of legacy pic16 microcontrollers. the pic16f1 and pic12f1 family of microcontrollers are a series of 8-bit microcontrollers derived from the popular pic16 series of 8-bit pic ? microcontrollers. the f1 derivatives feature an enhanced cpu, support for extended amounts of memory, improved peripherals, and xlp low power. the f1 evaluation platform allows you to evaluate these features for your application in a simple, low-cost platform. this chapter introduces the f1 evaluation platform: ? platform contents ? hardware features 1.2 platform contents the f1 evaluation platform contains the following items: 1. f1 evaluation platform demo board ? www.microchip.com/ f1eval 1.3 hardware features the f1 evaluation platform has the following hardware features: 1.3.1 pic16lf1937 the pic16lf1937 is a 40-pin full-featured device, including: 1. enhanced pic16 instruction set 2. 8k words of flash memory 3. 512 bytes of ram 4. 256 bytes of eeprom 5. 3 eccps, 2 ccps 6. mssp (i 2 c?, spi) 7. eusart 8. 8- and 16-bit timers 9. 32 mhz internal oscillator 10. low-power 32 khz crystal oscillator and 11. lcd controller. 1.3.2 mcp9800 i 2 c temperature sensor the mcp9800 is a low-power, selectable 8 to 12-bit i 2 c temperature sensor in a sot23-5 package.
f1 evaluation platform user?s guide DS41401A-page 12 ? 2009 microchip technology inc. 1.3.3 pickit? 3 programming/debug header the pickit 3 is a low-cost development tool that allows programming and debugging of the pic16lf1937 mcu. 1.3.4 pickit serial communications header the pickit serial is a low-cost development tool that allows i 2 c, spi and usart protocols to be monitored and debugged through a simple 6-pin connector. 1.3.5 1 button, 1 potentiometer, 4 leds simple applications need the basic user interface elements. the button, potentiometer and 1 led are available for any application. the remaining 3 leds are shared with the 20-bit motor control connector. 1.3.6 one 3.5 digit lcd the 3.5-digit lcd glass supplied on this board is a typical meter-type display with icons for ohms, amps, etc. the pic16lf1937 makes controlling this glass very simple. 1.3.7 20-pin motor control expansion connector this connector allows the pic16lf1937 to control an optional sensorless blcd add-on board (dm164130-2). the pic16lf1937 has complete control of 3 phases so other 1, 2, or 3-phase motor topologies can also be controlled. 1.3.8 current monitoring connector to demonstrate the xlp features, a precision ammeter can be connected to the current monitoring connector. this allows your application to be easily optimized for the lowest possible current. 1.3.9 generous prototyping area our circuits are not your circuits. a prototyping area has been provided to extend the functionality of this demo board to demonstrate the utility of the pic16lf1937 in your application.
f1 evaluation platform user?s guide ? 2009 microchip technology inc. DS41401A-page 13 chapter 2. getting started 2.1 introduction this chapter gives instruction to get your f1 evaluation platform powered up and running the default demonstration. ? powering the f1 evaluation platform ? default firmware ? programming the f1 evaluation platform with the pickit? 3 ? attaching a pickit serial (optional) ? measuring the current consumption figure 2-1: f1 evaluation platform (dm164130-1) 2.2 powering the f1 evaluation platform the pic16lf1937 supplied with your f1 evaluation platform requires a supply voltage of 1.8v-3.6v. voltages above 3.6v will degrade or damage the device. there are four ways to supply the necessary power. 1. use pickit 3, 2. use the power connector at jp3, 3. use pickit serial, or 4. use the blcd expansion header j3. 2.3 powering with pickit? 3 to power with the pickit 3, perform the following steps: 1. make sure a jumper or an ammeter is connected across jp2. 2. if you are using a bldc expansion, remove the jumper at jp1.
f1 evaluation platform user?s guide DS41401A-page 14 ? 2009 microchip technology inc. 3. configure the pickit 3 to supply a voltage between 1.8 and 3.6v. for proper lcd contrast, the supply should be 3.3v. 4. attach the pickit 3 to the pickit icsp? connector at the end of the board. 5. activate the pickit 3 power output. 2.4 powering with the connector at jp3 to power with the connector at jp3, perform the following steps: 1. make sure a jumper or an ammeter is connected across jp2. 2. if you are using a bldc expansion, remove the jumper at jp1. 3. verify the supply voltage to be between 1.8 and 3.6v. for proper lcd contrast, the supply should be 3.3v. 4. attach the power supply to jp3. 5. turn on the power supply. figure 2-2: powering with the connector at jp3 2.5 powering with pickit? serial to power with the pickit serial, perform the following steps: 1. make sure a jumper or an ammeter is connected across jp2. 2. if you are using a bldc expansion, remove the jumper at jp1. 3. configure the pickit serial to supply a voltage between 1.8 and 3.6v. for proper lcd contrast, the supply should be 3.3v. 4. attach the pickit serial to the pickit serial connector at the top corner of the board. 5. activate the pickit serial power output.
getting started ? 2009 microchip technology inc. DS41401A-page 15 2.6 powering with the bldc expansion header j3 the bldc expansion hardware contains a 3.3v linear regulator. this allows the 5-12v motor power supply to power the pic16lf1937. j3 pin 6 is the source for the 3.3v power. to use this power perform the following steps. 1. make sure a jumper or an ammeter is connected across jp2. 2. insert the shorting jumper at jp1. 3. verify that any attached pickit 3 or pickit serial is not supplying power. 4. verify that there is no power supply or shorting jumper at jp3. 5. verify that the bldc expansion hardware provides less than 3.6v of power. (the f1 bldc add-on supplies 3.3v) 6. attach the bldc expansion board. 7. supply power via the bldc board. 2.7 default firmware the default firmware supplied with your f1 evaluation board demo has the following features: 1. blink leds 2. measure the ambient temperature 3. run a bldc motor (or try to if no motor is attached) 4. display time/temperature/pot position/motor rpm on the lcd 5. user interface with a button and pot for the latest firmware go to www.microchip.com/f1eval 2.7.1 blinking leds the 4 leds indicate motor phase operation (d<2:4>) and the performance of the primary state machine loop (d1). 2.7.2 measuring the ambient temperature the mcp9800 is polled when in temperature measurement mode. the measured temperature is filtered, scaled to centigrade and displayed on the lcd. 2.7.3 bldc motor one task of the demo code is to drive a bldc motor attached to the bldc expansion header. the optional bldc controller board (dm164130-2) is required to drive the motor. the code performs a series of forced commutation steps to attempt a sensorless motor start. if no back emf signal is detected, the code repeats the start-up sequence. the leds blink at an increasing rate indicating the motor start attempts. if no motor drive hardware is attached, this pattern can repeat or it may detect a bemf signal in the noise present on the bemf sense inputs.
f1 evaluation platform user?s guide DS41401A-page 16 ? 2009 microchip technology inc. 2.7.4 lcd display the time, temperature, pot position and motor speed are displayed on the lcd. the lcd is a 3.5-digit multimeter display with icons for amps, volts, ohms, etc. the display uses 4 commons and 10 segment drives. the timer1 oscillator is used to clock the display peripheral and allow the display to show a picture even in sleep. the lcd peripheral was configured for a type b waveform for this demo. this mode provides an interrupt when the lcd can be updated. this interrupt is not required for type a waveforms, but the extra complexity of the interrupt allows the lcd peripheral to be used to provide the real-time clock periodic interrupt. the different waveform types are described in section 21.9 of the pic16lf193x data sheet (ds41364). normally, the timer1 counter would be used, but this timer is required for the bldc software. because the lcd is clocked from the 32.768 khz crystal, the lcdif operates at a multiple of the crystal frequency, providing a very accurate time base for the real-time clock. 2.7.5 user interface due to the extreme simplicity of this board, only a single button and a single pot are available for user input. these two elements allow the user to cycle through the display elements, change the motor speed and change the time. pressing and releasing the button cycles through the 4 display modes: 1. time 2. temperature 3. pot adc value 4. rpm turning the pot will change the motor speed or set the time. if the display is showing the time, and the button is held down for 3 seconds, turning the pot clockwise will increase the time, and counter clockwise will decrease the time. placing the pot in the center of the range will leave the time unchanged. a feature that could be added as a simple programming exercise would be to allow the time change to be faster or slower depending upon pot position.
f1 evaluation platform user?s guide ? 2009 microchip technology inc. DS41401A-page 17 chapter 3. programming th e f1 evaluation platform 3.1 introduction the f1 evaluation platform makes extensive use of the onboard peripherals of the pic16lf1937. this chapter provides guidance concerning the tools used for programming the f1 evaluation board and a map of the board function to i/o pin and pin function. 3.2 programming/development tool support the following development tools support the f1 evaluation platform: 1. pickit? 3 2. pickit? 2 3. real ice? in-circuit emulator (with adapter ac164110) the pickit? tools can also power the f1 evaluation platform, therefore, no additional hardware is required to get started. the icsp? pins of the pic16lf1937 are dedicated to the pickit icsp connector, eliminating interactions between the evaluation platform and the programmer/debugger. if you are developing with the real ice emulator, you will need the ac164110 adaptor, or the high-speed trace adaptor. these adaptors provide the inline 6 pin connector required by the pickit icsp programming capability interface. you will also need a power supply, please see chapter 2. ?getting started? for more on powering the f1 evaluation platform.
f1 evaluation platform user?s guide DS41401A-page 18 ? 2009 microchip technology inc. 3.3 hardware resources table 3-1: pin number pin name pin function used board function 1 rc7 eusart rx pickit? serial pin 1 2 rd4 segment 17 lcd pin 13, s1/s2/m/m 3 rd5 ccp1 output b bldc pin 5, phase u low drive 4 rd6 ccp1 output c bldc pin 9, phase v low drive 5 rd7 segment 20 lcd pin 14, a/v/k/omega 6v ss v ss v ss 7v dd v dd v dd 8 rb0 segment 0 lcd pin 5, rc/batt/-/ac 9 rb1 c12in3- bldc pin 19, phase v bemf zero cross 10 rb2 an8 potentiometer 11 rb3 c12in2- bldc pin 17, phase u bemf zero cross 14 rb4 com1 lcd pin 1, common 1 15 rb5 com2 lcd pin 2, common 2 16 rb6 pgc pickit 2 icsp? pin 5, pgc 17 rb7 pgd pickit 2 icsp pin 4, pgd 18 mclr mclr pickit icsp pin 1 19 ra0 segment 12 lcd pin 11, 1a/1f/1e/1d 20 ra1 c12in1- bldc pin 15, phase w bemf zero cross 21 ra2 com3 lcd pin 3, common 3 22 ra3 c1in+ bldc pin 16, bemf zero cross reference 23 ra4 segment 4 lcd pin 8, 3b/3g/3c/3dp 24 ra5 segment 5 lcd pin 9, 2a/2f/2e/2d 25 re0 re0 led d4 and bldc pin 3 phase w high drive 26 re1 re1 led d3 and bldc pin 7 phase u high drive 27 re2 re2 led d2 and bldc pin 11 phase v high drive 28 v dd v dd v dd 29 v ss v ss v ss 30 ra7 segment 2 lcd pin 7, 3a/3f/3e/3d 31 ra6 segment 1 lcd pin 6, dh/rh/b-c/4dp 32 rc0 t1osco 32.768 khz crystal drive 35 rc1 t1osci 32.768 khz crystal drive 36 rc2 ccp1 output a bldc pin 1, phase w low drive 37 rc3 mssp sclk mcp9800 sclk and pickit serial pin 5 38 rd0 common 4 lcd pin 4, common 4 39 rd1 rd1 led d1 40 rd2 rd2 button input 41 rd3 segment 16 lcd pin 12, 1b/1g/1c/ 42 rc4 mssp sda mcp9800 sda and pickit serial pin 4 43 rc5 segment 10 lcd pin 10, 2b/2g/2c/2dp 44 rc6 eusart tx pickit serial pin 6
f1 evaluation platform user?s guide ? 2009 microchip technology inc. DS41401A-page 19 chapter 4. demo code 4.1 introduction the f1 evaluation platform demos are located at www.microchip.com/f1eval . the following demos are available: 1. i 2 c? demo 2. lcd demo 3. bldc demo 4. combined demo this chapter provides an overview to the functions provided by these demos. 4.2 i 2 c? demo the i 2 c demo reads the current temperature from the on-board mcp9800 i 2 c temperature sensor. the i 2 c driver is used to extract the data. the resulting value is converted to a pwm duty cycles and used to control the brightness of the led d4. led d1 toggles at approximately 10 ms. 4.3 lcd demo the lcd demo adds button, potentiometer, real-time clock (rtc) and lcd support to the i 2 c demo. the 32.768 khz crystal is activated to maintain the real-time clock and to drive the lcd peripheral. an input driver is supplied to manage the button and potentiometer. a state machine now controls the major features of the demo so that the time, temperature and potentiometer value can be displayed on the lcd. 4.4 bldc demo the bldc demo controls a sensorless, brushless dc motor connected to the pic16f1 bldc expansion board (dm164130-2). other motors can also be driven by making appropriate modifications to the motor control parameters in the source code. 4.5 combined demo the combined demo combines all the software from all the previous demos to show the power of the pic16lf1937. in this demo, the bldc motor is seamlessly controlled while displaying the time, temperature, potentiometer position or motor rpm/10. all drivers are reused from the previous demos. the rtcc is driven from the lcd peripheral. the combined demo is preprogrammed in the f1 evaluation platform.
f1 evaluation platform user?s guide DS41401A-page 20 ? 2009 microchip technology inc. notes:
f1 evaluation platform user?s guide ? 2009 microchip technology inc. DS41401A-page 21 chapter 5. hardware libraries and drivers 5.1 introduction all of the demo code uses a common set of libraries to provide i 2 c, real-time clock, mcp9800 and lcd services. these libraries may be useful for other applications so they are documented here. these drivers are located at www.microchip.com/f1eval . 5.2 i 2 c? driver the i 2 c driver allows i 2 c requests to be queued and then handled either by interrupts or by polling. the driver is configured during compilation to support polling or interrupts. the i 2 c and lcd demos configure the driver for interrupt mode. the combined demo polls the i 2 c handler within the mcp9800 driver. 5.3 mcp9800 driver the mcp9800 driver uses the i 2 c driver to get the current temperature. the mcp9800_get_temp function is fully blocking, so once a request is queued, the driver polls the i 2 c subsystem until the data is complete. if the i 2 c driver is operating without interrupts, the mcp9800_get_temp function repeatedly calls the i2c_handler function to process all the i 2 c events. if the i 2 c driver is operating with interrupts, the mcp9800_get_temp function simply inserts an i2c_transaction_t into the i 2 c transaction queue and waits for the transaction to complete. 5.4 rtcc driver a software rtcc is managed by the supplied rtcc driver. this driver implements the time() function required by the c compiler. time is internally kept as seconds since january 1, 1970. standard c functions can be used to convert the time to the current date. this driver has two modes. in the first mode, it expects to be called once per second by the timer1 interrupt. in the second mode, it expects to be called on every lcd mode b frame. this allows the rtcc to keep accurate time even if timer1 is being used by some other function, such as the bldc motor driver. 5.5 lcd driver the lcd driver contains the initialization code required for the lcd peripheral and the mapping code required to control the 3.5-digit lcd supplied with this demo board. it is a good starting point for the lcd driver your unique application will require.
f1 evaluation platform user?s guide DS41401A-page 22 ? 2009 microchip technology inc. 5.6 using the i 2 c? driver the supplied software includes an i 2 c master mode driver with the following features: 1. interrupt driven or polled 2. queued requests 3. minimum memory requirements 4. uses restart to maximize bus bandwidth 5. multiple atomic i 2 c transactions allowed at each queue entry 6. completion flag for each queued block of i 2 c commands. 5.6.1 i 2 c data structures two data structures are defined to simplify interactions with the i 2 c driver. 5.6.1.1 i2c_results_t the i2c_results_t is an enumerated type with the following enumerations: the data completion flag for an i 2 c request is of type i2c_results_t . this flag will be i2c_request_pending until the request is complete. if the request completed without errors, the value will be i2c_request_complete . if there were errors, the value will reflect one of the other 4 error conditions. 5.6.1.2 i2c_t the i2c_t is a structure representing one transaction on the i 2 c bus. a transaction contains the following elements: 1. a 7- or 10-bit address. address type is determined automatically by the driver. r/w mode is implicit in the address and specified by bit 0 . 2. an 8-bit baud rate. this is the value placed in spadd. predefined constants are included that compute the spadd value given an fosc value. set fosc with a #define before #including the i2c.h file. 3. a buffer_length . this is the number of bytes available for reading or writing at the supplied data buffer. 4. a buffer pointer. your application will allocate a block of memory for an i 2 c transaction. pass a pointer to this block via the buffer pointer. the block must remain valid until the transaction is complete (i.e. if you allocate the block as a non-static array within a function, you must not leave the function until the i 2 c transaction is complete or the array may be reused by a different function). table 5-1: i2c_results_t i2c_request_pending request is in the queue or in process but it is not done. i2c_request_complete the request is finished successfully. i2c_request_stuck_start the request was aborted. the start condition did not clear correctly. i2c_request_address_no_ack the request was aborted. no ack occurred on the address, so the target device must not exist or is not functioning. i2c_request_data_no_ack the request was aborted. not all of the data could be sent because the device did not ack a byte. i2c_request_lost_state the i 2 c state machine had a ram corruption and the default case caught the failure. this will infinite loop so you should never see it.
hardware libraries and drivers ? 2009 microchip technology inc. DS41401A-page 23 5.6.2 i 2 c function interface 5.6.2.1 i2c_init the function i2c_init configures the i 2 c driver and makes it ready to receive transaction in the transaction queue. figure 5-1: 5.6.2.2 i2c_insert the function i2c_insert places one complete set of transaction request block (trb?s). trbs can be bundled into an array of multiple trbs and inserted as one large request. the driver will ensure that all the trbs in the list will be processed sequentially with i 2 c restarts separating them. figure 5-2: 5.6.2.3 i2c_build_write_trb / i2c_build_read_trb the i2c_build_write_trb and i2c_build_read_trb functions are helpers to assemble the i2c_transaction_request_blocks from passed parameters. figure 5-3: 5.6.2.4 i2c_write_block / i2c_read_block the i2c_write_block and i2c_read_block functions are helpers that assemble a trb, insert it into the queue and wait for the transaction to complete. initialize() { i2c_init(i2c_400k); } send_data() { i2c_transaction_request_block trb_list[5]; i2c_results flag; ? populate the trb?s ? i2c_insert(5,trb_list, &flag); } send_one_byte() { i2c_transaction_request_block trb_list; unsigned char data; i2c_results flag; data_block = .. my data byte .. i2c_build_write_trb(&trb_list,address, 1, &data, i2c_200k); i2c_insert(1,&trb,&flag); }
f1 evaluation platform user?s guide DS41401A-page 24 ? 2009 microchip technology inc. figure 5-4: 5.6.2.5 i2c_handler the i2c_handler function must be called for each i 2 c state to be handled. this function can be placed into the interrupt service routine for your application or, you can simply poll it often. if the i2c_write_block or i2c_read_block functions are used when the driver is configured for polling, then this function will repeatedly be called until the transaction completes. figure 5-5: 5.7 using the lcd driver the supplied lcd driver configures the lcd module for the i/o pins used by the f1 evaluation platform. icon definitions are provided to simplify the software. a bcd to 7-segment display mapping function is also provided to further simplify control of the lcd glass. for more information concerning the lcd peripheral, please consult the lcd chapter in the pic16lf1937 data sheet (ds41364). 5.7.1 lcd data structures 5.7.1.1 bcd_type to simplify bcd to the 7-segment display mapping, a bcd segment data type has been provided. this data type is simply four 4-bit fields representing digits 0, 1, 2, and 3. figure 5-6: simply place the number you want displayed in each digit position and call lcd_display_digits . digit 3 is the most significant ? digit of the 3.5-digit lcd glass. therefore, the largest value displayable is 1fff assuming hexidecimal digits or 1999 for decimal digits. send_one_byte() { unsigned char data; i2c_write_block(address, 1, &data, i2c_200k); } interrupt_service_routine() { i2c_handler(); } typedef union { uint16 val; struct { unsigned digit0 : 4; unsigned digit1 : 4; unsigned digit2 : 4; unsigned digit3 : 4; }; } bcd_type;
hardware libraries and drivers ? 2009 microchip technology inc. DS41401A-page 25 5.7.2 lcd function interface 5.7.2.1 lcd_init this function configures the lcd peripheral for this board and this glass. type b waveforms are used to allow the lcd peripheral to be used for the real time clock function. the timer1 oscillator is configured as the lcd clock source. figure 5-7: 5.7.2.2 lcd_display_digits this function accepts a bcd_type variable and maps each digit to the correct segments. mapping the segments is done in two stages. first, the digit is converted to the correct 7-segment mapping. then, the 7-segment mapping is converted to the actual glass segments with a long series of ?if-else? statements. this function will need extensive work in the ?if-else? statements for applications driving different glass. figure 5-8: 5.7.2.3 lcd_display_on / lcd_display_off these two functions simply turn the lcd peripheral off. the timer1 oscillator is left running. one use for these functions is to implement display blinking. figure 5-9: system_initialize() { lcd_init(); } void display_int(int t) { bcd_type bcd; bcd.digit0 = t %10; t /= 10; bcd.digit1 = t % 10; t /= 10; bcd.digit2 = t % 10; t /= 10; bcd.digit3 = t%10; lcd_display_digits(bcd); } void update_blinking() { if(time(0) % 2) // if an odd number of seconds { lcd_display_on(); } else { lcd_display_off(); } }
f1 evaluation platform user?s guide DS41401A-page 26 ? 2009 microchip technology inc. 5.7.3 lcd segment definitions figure 5-10: lcd display there are many segments present on the f1 evaluation platform lcd. to access these segments, simply set the supplied #defines to 1 or 0 . figure 5-11: 5.8 using the rtcc driver the rtc driver simply keeps track of seconds. the power-up initial value is ? 0 ?, however a function ( rtcc_set ) is provided to change that value. to keep the seconds up-to-date, the function, rtcc_handler , must be called more frequently than the defined value of clocks_per_second. there are two options for the rtcc driver. the first option is to use the timer1 counter to provide a 1 hz interrupt (clocks_per_second = 1). the second option is to use the lcd write-allowed interrupt flag to provide a 128 hz event (clocks_per_second = 128). the two choices are selected by defining use_lcdif or undefining use_lcdif . 5.8.1 rtcc function interface 5.8.1.1 rtcc_init intialize the rtcc function including timer1, if required. void display_volts(int v) { display_int(v); dp3 = 0; dp2 = 0; s1 = 0; s2 = 0; amps = 0; volt = 1; kilo = 0; ohms = 0; if (v < 0) minus = 1; else minus = 0; }
hardware libraries and drivers ? 2009 microchip technology inc. DS41401A-page 27 figure 5-12: 5.8.1.2 rtcc_handler the rtcc_handler function must be called frequently to keep the internal seconds counter accurate. figure 5-13: 5.8.1.3 rtcc_set after system initialization, the seconds counter is cleared to ? 0 ?. the standard c libraries equate 0 seconds to midnight, jan 1, 1970. that time has expired a long time ago, so a new time in seconds can be configured with rtcc_set() . figure 5-14: 5.8.1.4 time the standard c libraries require the application to supply the time function. this function returns the current time_t value or loads a supplied time_t value. the interrupts are saved and restored to make this function safe for use with interrupt driven code. 5.9 using the mcp9800 driver the mcp9800 is an i 2 c temperature sensor. the mcp9800 driver provides a simple interface to the features in the sensor. system_initialization() { rtcc_init(); } system_interrupt_service_routine() { if(tmr1if & tmr1ie) { tmr1if = 0; rtcc_handler(); } } #include time_set() // set the time & date to 1 second after midnight, july 4, 2009 { struct tm time_str; time_t unix_time; time_str.tm_year = 2009; // the year time_str.tm_mon = 7; // the month time_str.tm_mday = 4; // the day of the month time_str.tm_hour = 0; // the hour (0-23) time_str.tm_min = 0; // the minutes time_str.tm_sec = 1; // the seconds time_str.tm_isdst = -1; // daylight savings time modifier unix_time = mktime(&time_str); rtcc_set(unix_time); }
f1 evaluation platform user?s guide DS41401A-page 28 ? 2009 microchip technology inc. 5.9.1 mcp9800 function interface 5.9.1.1 mcp9800_init this function configures the mcp9800 for 12-bit temperature, continuous conversion mode. in this mode, the temperature is always ready to be read from the i 2 c interface. figure 5-15: 5.9.1.2 mcp9800_get_temp this function reads the current temperature and scales the result to degrees c * 10. (24.3c is returned 243) figure 5-16: system_init() { i2c_init(); mcp9800_init(); } thermostat() { int temperature; temperature = mcp9800_get_temp(); if(temperature > 260) { turn_on_air_conditioner(); } }
f1 evaluation platform user?s guide ? 2009 microchip technology inc. DS41401A-page 29 chapter 6. troubleshooting 6.1 introduction there may come a time when you need to determine why your f1 evaluation platform is not performing correctly. this chapter lists a few of the problems that can prevent proper operation. 6.2 common problems 6.2.1 the board will not power up make sure there is no shorting jumper at jp3. then, go back and review chapter 2. ?getting started? of this manual. 6.2.2 lcd is blank, but everything else works the demo code in supplied with your f1 evaluation platform uses the timer1 oscillator to drive the lcd. if the timer1 oscillator is not oscillating, the lcd will remain blank. here are some steps to assure that your timer1 oscillator is working properly. 1. clean and dry the board especially around the components at the top right corner of the pic16lf1937. 2. make sure no foreign material is shorting the crystal leads. 3. if you are using the rc0 and rc1 pins for some other function, you should modify lcd_init to reconfigure the lcd peripheral for a different clock source. the timer1 oscillator of the pic16lf1937 is a very low-power design that can be easily disrupted by stray leakage. in an actual application, microchip recommends that the crystal circuit be conformal coated to prevent leakage. please review application note an1288, ?design practices for low-power external oscillators? for more information. 6.2.3 the motor spins, but then stops the bldc start-up algorithm could be having trouble finding the bemf zero-crossing signal required to synchronize the motor commutation. if you have attached the bldc add-on board and you are using the supplied bldc motor, then the pot labeled iref needs to be turned completely counter clockwise to assure that a good bemf zero-crossing signal is detected by the pic16lf1937. if you are using a different motor, you need to adjust the zero-crossing threshold to match the requirements of the motor. for more information, consult the documentation supplied with the bldc add-on board.
f1 evaluation platform user?s guide DS41401A-page 30 ? 2009 microchip technology inc. notes:
f1 evaluation platform user?s guide ? 2009 microchip technology inc. DS41401A-page 31 chapter 7. schematics 7.1 introduction to help understand the features of the f1 evaluation platform and the bldc add-on board, the schematics are included here.
f1 evaluation platform user?s guide DS41401A-page 32 ? 2009 microchip technology inc. 7.1.1 f1 evaluation platform schematic (1 of 3) 
schematics ? 2009 microchip technology inc. DS41401A-page 33 7.1.2 f1 evaluation platform schematic (2 of 3)
f1 evaluation platform user?s guide DS41401A-page 34 ? 2009 microchip technology inc. 7.1.3 f1 evaluation platform schematic (3 of 3)
schematics ? 2009 microchip technology inc. DS41401A-page 35 7.1.4 bldc add-on schematic (1 of 3)
f1 evaluation platform user?s guide DS41401A-page 36 ? 2009 microchip technology inc. 7.1.5 bldc add-on schematic (2 of 3)
schematics ? 2009 microchip technology inc. DS41401A-page 37 7.1.6 bldc add-on schematic (3 of 3)
f1 evaluation platform user?s guide DS41401A-page 38 ? 2009 microchip technology inc. notes:
f1 evaluation platform user?s guide ? 2009 microchip technology inc. DS41401A-page 39 index numerics 2c demo .................................................................. 19 3.5-digit lcd ............................................................ 12 a ac164110 ................................................................ 17 ammeter .................................................................. 14 b bemf zero crossing signal ...................................... 29 bldc demo ............................................................. 19 bldc expansion ...................................................... 14 bldc motor ............................................................. 15 c c12in3-.................................................................... 18 ccp1 output a ........................................................ 18 ccp1 output b ........................................................ 18 ccp1 output c ........................................................ 18 centigrade ............................................................... 15 com1....................................................................... 18 com2....................................................................... 18 com3....................................................................... 18 combined demo ...................................................... 19 common problems .................................................. 29 customer notification service.................................... 8 customer support ...................................................... 9 d documentation conventions........................................................ 6 layout ................................................................. 5 e enhanced midrange microcontrollers....................... 11 eusart rx ............................................................ 18 f f1 evaluation platform............................................. 11 f1 evaluation platform schematic ........................... 32 h hardware features .................................................. 11 16-bit timers ...................................................... 11 32-mhz internal oscillator ................................. 11 eccp ................................................................ 11 eeprom .......................................................... 11 eusart ........................................................... 11 lcd controller ................................................... 11 ram.................................................................. 11 hardware libraries & drivers ................................... 21 i icsp pins ................................................................. 17 internet address......................................................... 8 l lcd demo ............................................................... 19 lcd display ............................................................. 15 lcd function interface ............................................ 25 lcd_display_digits.............................................. 25 lcd_display_on / lcd_display_off ....................... 25 lcd_init............................................................... 25 linear regulator ........................................................ 15 m mclr ....................................................................... 18 mcp9800 ................................................................. 11 temperature sensor.......................................... 11 microchip internet web site ....................................... 8 mssp sclk............................................................. 18 mssp sda............................................................... 18 p pgc ......................................................................... 18 pgd ......................................................................... 18 pic? microcontrollers .............................................. 11 pic16 series............................................................. 11 pic16f1 evaluation kit ............................................ 11 pic16f1 family......................................................... 11 pic16lf1937 ........................................................... 11 pickit icsp? programming capability interface...... 17 pickit serial ............................................................. 14 pickit serial connector............................................. 14 pickit serial power output........................................ 14 pickit? 2 ................................................................. 17 pickit? 3 ................................................................. 17 platform contents .................................................... 11 f1 evaluation platform demo board ................ 11 powering with pickit 3 ............................................. 13 jp1.................................................................... 13 jp2.................................................................... 13 pickit icsp connector ...................................... 14 voltage.............................................................. 14 programming & debugging ...................................... 12 r rd1 .......................................................................... 18 rd2 .......................................................................... 18 re0 .......................................................................... 18 re1 .......................................................................... 18 re2 .......................................................................... 18 reading, recommended ........................................... 7 readme...................................................................... 7
f1 evaluation platform user?s guide DS41401A-page 40 ? 2009 microchip technology inc. real ice? in-circuit emulator ................................ 17 s segment 17 .............................................................. 18 sensorless blcd add-on board............................... 12 supply voltage.......................................................... 13 t t1osci .................................................................... 18 t1osco .................................................................. 18 u user interface........................................................... 16 pot adc value .................................................. 16 rpm .................................................................. 16 temperature ..................................................... 16 time .................................................................. 16 w warranty registration................................................. 7 www address ........................................................... 8 x xlp low power ......................................................... 11
? 2009 microchip technology inc. DS41401A-page 41 f1 evaluation platform user?s guide notes:
DS41401A-page 42 ? 2009 microchip technology inc. americas corporate office 2355 west chandler blvd. chandler, az 85224-6199 tel: 480-792-7200 fax: 480-792-7277 technical support: http://support.microchip.com web address: www.microchip.com atlanta duluth, ga tel: 678-957-9614 fax: 678-957-1455 boston westborough, ma tel: 774-760-0087 fax: 774-760-0088 chicago itasca, il tel: 630-285-0071 fax: 630-285-0075 cleveland independence, oh tel: 216-447-0464 fax: 216-447-0643 dallas addison, tx tel: 972-818-7423 fax: 972-818-2924 detroit farmington hills, mi tel: 248-538-2250 fax: 248-538-2260 kokomo kokomo, in tel: 765-864-8360 fax: 765-864-8387 los angeles mission viejo, ca tel: 949-462-9523 fax: 949-462-9608 santa clara santa clara, ca tel: 408-961-6444 fax: 408-961-6445 toronto mississauga, ontario, canada tel: 905-673-0699 fax: 905-673-6509 asia/pacific asia pacific office suites 3707-14, 37th floor tower 6, the gateway harbour city, kowloon hong kong tel: 852-2401-1200 fax: 852-2401-3431 australia - sydney tel: 61-2-9868-6733 fax: 61-2-9868-6755 china - beijing tel: 86-10-8528-2100 fax: 86-10-8528-2104 china - chengdu tel: 86-28-8665-5511 fax: 86-28-8665-7889 china - hong kong sar tel: 852-2401-1200 fax: 852-2401-3431 china - nanjing tel: 86-25-8473-2460 fax: 86-25-8473-2470 china - qingdao tel: 86-532-8502-7355 fax: 86-532-8502-7205 china - shanghai tel: 86-21-5407-5533 fax: 86-21-5407-5066 china - shenyang tel: 86-24-2334-2829 fax: 86-24-2334-2393 china - shenzhen tel: 86-755-8203-2660 fax: 86-755-8203-1760 china - wuhan tel: 86-27-5980-5300 fax: 86-27-5980-5118 china - xiamen tel: 86-592-2388138 fax: 86-592-2388130 china - xian tel: 86-29-8833-7252 fax: 86-29-8833-7256 china - zhuhai tel: 86-756-3210040 fax: 86-756-3210049 asia/pacific india - bangalore tel: 91-80-3090-4444 fax: 91-80-3090-4080 india - new delhi tel: 91-11-4160-8631 fax: 91-11-4160-8632 india - pune tel: 91-20-2566-1512 fax: 91-20-2566-1513 japan - yokohama tel: 81-45-471- 6166 fax: 81-45-471-6122 korea - daegu tel: 82-53-744-4301 fax: 82-53-744-4302 korea - seoul tel: 82-2-554-7200 fax: 82-2-558-5932 or 82-2-558-5934 malaysia - kuala lumpur tel: 60-3-6201-9857 fax: 60-3-6201-9859 malaysia - penang tel: 60-4-227-8870 fax: 60-4-227-4068 philippines - manila tel: 63-2-634-9065 fax: 63-2-634-9069 singapore tel: 65-6334-8870 fax: 65-6334-8850 taiwan - hsin chu tel: 886-3-6578-300 fax: 886-3-6578-370 taiwan - kaohsiung tel: 886-7-536-4818 fax: 886-7-536-4803 taiwan - taipei tel: 886-2-2500-6610 fax: 886-2-2508-0102 thailand - bangkok tel: 66-2-694-1351 fax: 66-2-694-1350 europe austria - wels tel: 43-7242-2244-39 fax: 43-7242-2244-393 denmark - copenhagen tel: 45-4450-2828 fax: 45-4485-2829 france - paris tel: 33-1-69-53-63-20 fax: 33-1-69-30-90-79 germany - munich tel: 49-89-627-144-0 fax: 49-89-627-144-44 italy - milan tel: 39-0331-742611 fax: 39-0331-466781 netherlands - drunen tel: 31-416-690399 fax: 31-416-690340 spain - madrid tel: 34-91-708-08-90 fax: 34-91-708-08-91 uk - wokingham tel: 44-118-921-5869 fax: 44-118-921-5820 w orldwide s ales and s ervice 03/26/09


▲Up To Search▲   

 
Price & Availability of DS41401A

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X